import { SiegeUnionPartBase } from "./SiegeUnionPartBase";
import { ResouceConst } from "../../../../../component/gconst/ResouceConst";
import { SiegeInfoCellRender } from "./SiegeInfoCellRender";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { SecTimer } from "../../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../../com/gengine/core/frame/TimerType";
//class SiegeInfoPart
    
    export  class SiegeInfoPart extends SiegeUnionPartBase
    {
        constructor(arg1: string="", arg2: Boolean=true, arg3: string="", arg4: number=590, arg5: number=480)
        {
            super(arg1, arg2, arg3, arg4, arg5);
            return;
        }

        protected /* override */ configUI(): void
        {
            var loc1=ResouceConst.getScaleBitmap("RbListHeader");
            loc1.width = 792;
            loc1.height = 35;
            addChild(loc1);
            this._nameBmp1 = new Object /* flash.display.Bitmap */();
            this._nameBmp2 = new Object /* flash.display.Bitmap */();
            this._nationPowerBmp1 = new Object /* flash.display.Bitmap */();
            this._nationPowerBmp2 = new Object /* flash.display.Bitmap */();
            this._battleCDTimeBmp = new Object /* flash.display.Bitmap */();
            this._battleResultBmp = new Object /* flash.display.Bitmap */();
            super.configUI();
            this._bottomPart.y = 332;
            --this._bottomPart.x;
            this._cellList.rowCount = 9;
            this._cellList.columnCount = 1;
            this._cellList.rowHeight = 31;
            this._cellList.columnWidth = 792;
            this._cellList.verticalGap = 2;
            this._cellList.setSize(792, 298);
            this._cellList.move(0, 28);
            this._cellList.setStyle("cellRenderer", SiegeInfoCellRender);
            this.addChild(this._nameBmp1);
            this.addChild(this._nameBmp2);
            this.addChild(this._nationPowerBmp1);
            this.addChild(this._nationPowerBmp2);
            this.addChild(this._battleCDTimeBmp);
            this.addChild(this._battleResultBmp);
            if (_unionInviteBtn && _unionInviteBtn.parent) 
            {
                _unionInviteBtn.parent.removeChild(_unionInviteBtn);
            }
            return;
        }

        protected /* override */ onImageLoaded(): void
        {
            this._nameBmp1.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_name);
            this._nameBmp2.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_name);
            this._nationPowerBmp1.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_nationPower);
            this._nationPowerBmp2.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_nationPower);
            this._battleCDTimeBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_cdTime);
            this._battleResultBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_battleResult);
            this._nameBmp1.x = 63;
            this._nameBmp1.y = 11;
            this._nationPowerBmp1.x = 181;
            this._nationPowerBmp1.y = this._nameBmp1.y;
            this._nameBmp2.x = 392;
            this._nameBmp2.y = this._nameBmp1.y;
            this._nationPowerBmp2.x = 500;
            this._nationPowerBmp2.y = this._nameBmp2.y;
            this._battleCDTimeBmp.y = this._nameBmp2.y;
            this._battleCDTimeBmp.x = 586;
            this._battleResultBmp.y = this._nameBmp2.y;
            this._battleResultBmp.x = 691;
            return;
        }

        /* internal  */startTimer(): void
        {
            if (!this._secTimer) 
            {
                this._secTimer = new SecTimer(1);
                this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimerRun);
            }
            this._secTimer.reset();
            this._secTimer.start();
            return;
        }

        /* internal  */onTimerRun(arg1: SecTimer): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=this._cellList.dataProvider.length;
            var loc4=0;
            while (loc4 < loc1) 
            {
                loc2 = this._cellList.getItemAt(loc4);
                if (loc2) 
                {
                    if (loc3 = this._cellList.itemToCellRenderer(loc2) as SiegeInfoCellRender) 
                    {
                        loc3.updateTime();
                    }
                }
                ++loc4;
            }
            return;
        }

        /* internal  */stopTimer(): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.stopTimer();
            return;
        }

        public /* override */ show(arg1: Object /* flash.display.DisplayObjectContainer */): void
        {
            super.show(arg1);
            this.startTimer();
            return;
        }

        /* internal */ /* var */_nameBmp1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nationPowerBmp1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameBmp2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nationPowerBmp2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_battleCDTimeBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_battleResultBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_secTimer: SecTimer;
    }
